// app.js
// var QQMapWX = require('./utils/qqmap-wx-jssdk.min.js');
App({
  onLaunch() {
    this.getSystemInfo();
    this.getConfig().then(res=>{
      if(Object.prototype.toString.call(res).toLowerCase() == '[object object]'){
        wx.setStorageSync('SYSTEM_CONFIG', res)
      }
    })
  },
  getSystemInfo() {
    let {
      statusBarHeight,
      platform
    } = wx.getSystemInfoSync();
    let {
      top,
      height,
      bottom
    } = wx.getMenuButtonBoundingClientRect();
    let capsule = height ? height : 32;
    let navigationBarHeight = statusBarHeight?statusBarHeight:(platform === 'android' ? 48 : 40);
    if (top && top !== 0 && height && height !== 0) {
      capsule = top+bottom + height;
    }
    wx.setStorageSync('navBarObj', {
      bangsHeight:navigationBarHeight+capsule,
      capsule,
      statusBarHeight
    })
  },
  getConfig(){
    return new Promise((o, r)=>{
      wx.request({
        url: this.globalData.baseUrl + 'wechat/Apiwechat/share_config',
        method: "GET",
        header: {
          'content-type': 'application/x-www-form-urlencoded;charset=utf-8',
        },
        success: function (e) {
          if(e.data.code == 1){
            o(e.data.data);
          }else{
            r(false);
          }
        },
        fail: function (e) {
          r(false);
        }
      });
    });
  },
  globalData: {
    mapKey:'YW7BZ-PYXL5-CU5I2-IP5NT-QET6O-SAF4V',
    userInfo: null,
    // baseUrl: "https://sh.service199.com/index.php?s=/api/",
    baseUrl: "https://sh.service199.com/api/",
    pathUrl: "https://sh.service199.com/",
    baseImgUrl: "https://sh.service199.com/public/uploads/image/",
    basevideoUrl: "https://sh.service199.com/public/uploads/video/",
  }
})